<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>生成项目</title>
    <jsp:include page="/WEB-INF/view/commons/css.jsp" />
</head>
<body >
<div id="main-container" class="container-fluid">
    <form  action="genproject/${action eq "create" ?"save":"update"}" name="inputForm" id="inputForm" method="post" class="form-horizontal">
        <input name="id" id="id" value="${entity.id}" type="hidden" />
        <div class="form-group">
            <label class="col-sm-1 control-label">项目名称：</label>
            <div class="col-md-4">
                <input type="text" class="form-control" name="proName" value="${entity.proName}" placeholder="项目名称">
            </div>
            <label class="col-sm-2 control-label">项目基础包：</label>
            <div class="col-md-4">
                <input type="text" class="form-control" name="proPackage" value="${entity.proPackage}" placeholder="项目基础包">
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-1 control-label">版本：</label>
            <div class="col-md-4">
                <input type="text" class="form-control" name="proVersion" value="${entity.proVersion}" placeholder="版本">
            </div>
            <label class="col-sm-2 control-label">备注：</label>
            <div class="col-md-4">
                <input type="text" class="form-control" name="remark" value="${entity.remark}" placeholder="备注">
            </div>
        </div>
        <div id="lastRow" class="form-group">
            <div class="col-sm-offset-1 col-sm-2">
                <button id="saveBtn" type="submit" class="btn btn-sm btn-primary"><i class="fa fa-floppy-o"></i> 提交</button>
                <button type="button" class="btn btn-sm link_close"><i class="fa fa-close"></i> 关闭</button>
            </div>
        </div>
    </form>
</div><!--/#main-container-->

<!-- script start -->
<jsp:include page="/WEB-INF/view/commons/js.jsp" />
<script type="text/javascript">
    $(document).ready(function(e) {
        var options = {
            rules:{
                proName:{required:true},
                proPackage:{required:true},
                proVersion:{required:true}
            },
            submitHandler:function(form){

                $('.moduleRow').each(function(i,item){
                    $(this).find('input[type=text]').each(function(j){
                        var name = $(this).attr('name');
                        if(name.indexOf('.') > 0){
                            name = name.substring(name.indexOf('.') + 1);
                        }
                       $(this).attr('name', 'modules['+ i + '].'+ name);
                    });
                });

                $(form).ajaxSubmit({
                    type:'post',
                    dataType:'json',
                    success:function(data){
                        if(data.success){
                            $('#searchBtn', parent.document).click();
                            closeIframe();
                        }else{
                            layer.alert(data.msg);
                        }
                    }
                });
            }
        };
        $("#inputForm").validate(options);
    });
</script>

<!-- script end -->
</body>
</html>
